package com.cs.common.vo;

import com.cs.common.enums.ReturnEnum;

import lombok.Data;

@Data
public class ReturnVo<T> {
	private Integer code;
	private String message;
	private T data;
	
	private void init(Integer code, String message, T data) {
    	this.code = code;
    	this.message = message;
    	this.data = data;
    }
	
	public ReturnVo<T> success() {
        this.init(ReturnEnum.SUCCESS.getCode(), "", null);
        return this;  
    }
	
	public ReturnVo<T> success(String message) {
        this.init(ReturnEnum.SUCCESS.getCode(), message, null);
        return this;
    }
	
	public ReturnVo<T> success(String message, T data) {
		this.init(ReturnEnum.SUCCESS.getCode(), message, data);
        return this;
    }
	
	public ReturnVo<T> failure(String message) {
        this.init(ReturnEnum.ERROR.getCode(), message, null);
        return this;  
    }
	
	public ReturnVo<T> failure(String message, T data) {
        this.init(ReturnEnum.ERROR.getCode(), message, data);
        return this;  
    }
}
